package com.yuanhua.sim.controller;

import com.yuanhua.core.base.R;
import com.yuanhua.core.base.entity.MsgReqBean;
import com.yuanhua.sim.service.NettyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author yuanhua
 */
@RestController
@RequestMapping("/netty")
@Api(tags = "通讯控制器")
public class NettyServerController {

    @Resource
    private NettyService nettyService;

    @PostMapping("/send")
    @ApiOperation("私聊")
    public R<Boolean> sendMsg(@RequestBody MsgReqBean msgReqBean){
        //获取接收方用户id
        Boolean res = nettyService.sendMsg(msgReqBean);
        if (res){
            return R.success();
        }
        return R.fail(209, "人不在线");
    }

}